﻿using Dimebrain.TweetSharp.Model;

namespace KickStart.Data
{
    public class UserService
    {

        public static User GetUser(long userId)
        {
            return User.SingleOrDefault(u => u.UserId == userId);
        }

        public static void CreateUser(TwitterUser twitterUser, OAuthToken access)
        {
            var u = new User
                        {
                            UserId = twitterUser.Id,
                            ScreenName = twitterUser.ScreenName,
                            Token = access.Token,
                            TokenSecret = access.TokenSecret
                        };
            u.Save();

        }

        public static void UpdateUser(TwitterUser twitterUser, OAuthToken access)
        {
            var u = new User
            {
                UserId = twitterUser.Id,
                ScreenName = twitterUser.ScreenName,
                Token = access.Token,
                TokenSecret = access.TokenSecret
            };
            u.Update();

        }
    }
}
